package Abnormal;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * 2：计算平均课时:输入总课时和课程数,
 * 计算平均课时.要求捕捉输入和除法错误;如果总课时少于100,抛出课时太少的错误
 */
public class Subject {

    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入总课时");
        try {
            int a = in.nextInt();
            if (a < 100) {
               throw new Exception("课时太少了，错误");
            } else {
                System.out.println("请输入课程数");
                int b = in.nextInt();
                int c = a / b;
                System.out.println("平均课时为" + c);
            }

        } catch (InputMismatchException e) {
            System.out.println("输入错误" + e);
        } catch (ArithmeticException e) {
            System.out.println("除法错误" + e);
        } catch (Exception e) {
            System.out.println("其他异常" + e);
        } finally {
            System.out.println("感谢使用!");

        }
    }
}